home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / VISCAFE.BIN / VPOJAVA.DLL / SOURCE / SIMPLEAPP < prev    next >
Encoding:
Text File  |  1997-06-19  |  2.8 KB  |  123 lines

  1. /*
  2.     This simple extension of the java.awt.Frame class
  3.     contains all the elements necessary to act as the
  4.     main window of an application.
  5.  */
  6.  
  7. import java.awt.*;
  8.  
  9. public class Frame1 extends Frame {
  10.     void Open_Action(Event event) {
  11.         //{{CONNECTION
  12.         // Action from Open... Show the OpenFileDialog
  13.         openFileDialog1.show();
  14.         //}}
  15.     }
  16.  
  17.     void About_Action(Event event) {
  18.         //{{CONNECTION
  19.         // Action from About Create and show as modal
  20.         (new AboutDialog(this, true)).show();
  21.         //}}
  22.     }
  23.  
  24.     void Exit_Action(Event event) {
  25.         //{{CONNECTION
  26.         // Action from Exit Create and show as modal
  27.         (new QuitDialog(this, true)).show();
  28.         //}}
  29.     }
  30.  
  31.     public Frame1() {
  32.  
  33.         //{{INIT_CONTROLS
  34.         setLayout(null);
  35.         // addNotify();
  36.         resize(insets().left + insets().right + 405,insets().top + insets().bottom + 305);
  37.         openFileDialog1 = new java.awt.FileDialog(this, "Open",FileDialog.LOAD);
  38.         //$$ openFileDialog1.move(37,277);
  39.         setTitle("A Basic Application");
  40.         //}}
  41.  
  42.         //{{INIT_MENUS
  43.         mainMenuBar = new java.awt.MenuBar();
  44.  
  45.         menu1 = new java.awt.Menu("File");
  46.         menu1.add("New");
  47.         menu1.add("Open...");
  48.         menu1.add("Save");
  49.         menu1.add("Save As...");
  50.         menu1.addSeparator();
  51.         menu1.add("Exit");
  52.         mainMenuBar.add(menu1);
  53.  
  54.         menu2 = new java.awt.Menu("Edit");
  55.         menu2.add("Cut");
  56.         menu2.add("Copy");
  57.         menu2.add("Paste");
  58.         mainMenuBar.add(menu2);
  59.  
  60.         menu3 = new java.awt.Menu("Help");
  61.         mainMenuBar.setHelpMenu(menu3);
  62.         menu3.add("About");
  63.         mainMenuBar.add(menu3);
  64.         setMenuBar(mainMenuBar);
  65.         //$$ mainMenuBar.move(4,277);
  66.         //}}
  67.     }
  68.  
  69.     public Frame1(String title) {
  70.         this();
  71.         setTitle(title);
  72.     }
  73.  
  74.     public synchronized void show() {
  75.         move(50, 50);
  76.         super.show();
  77.     }
  78.  
  79.     public boolean handleEvent(Event event) {
  80.         if (event.id == Event.WINDOW_DESTROY) {
  81.             hide();         // hide the Frame
  82.             dispose();      // free the system resources
  83.             System.exit(0); // close the application
  84.             return true;
  85.         }
  86.         return super.handleEvent(event);
  87.     }
  88.  
  89.     public boolean action(Event event, Object arg) {
  90.         if (event.target instanceof MenuItem) {
  91.             String label = (String) arg;
  92.             if (label.equalsIgnoreCase("Open...")) {
  93.                 Open_Action(event);
  94.                 return true;
  95.             } else
  96.             if (label.equalsIgnoreCase("About")) {
  97.                 About_Action(event);
  98.                 return true;
  99.             } else
  100.                 if (label.equalsIgnoreCase("Exit")) {
  101.                     Exit_Action(event);
  102.                     return true;
  103.             }
  104.         }
  105.         return super.action(event, arg);
  106.     }
  107.  
  108.     static public void main(String args[]) {
  109.         (new Frame1()).show();
  110.     }
  111.  
  112.     //{{DECLARE_CONTROLS
  113.     java.awt.FileDialog openFileDialog1;
  114.     //}}
  115.  
  116.     //{{DECLARE_MENUS
  117.     java.awt.MenuBar mainMenuBar;
  118.     java.awt.Menu menu1;
  119.     java.awt.Menu menu2;
  120.     java.awt.Menu menu3;
  121.     //}}
  122. }
  123.